package lamma.lab.job.test;

import java.lang.reflect.Method;
import java.util.HashSet;
import java.util.Set;

import lamma.lab.job.Step;

public class JobHealthChecker {
	
	public static void check(Class<?> clazz) throws NonUniqueSerialException {
		Class<?> jobClazz = clazz;

		// used for validation checking for unique 
		Set<Integer> serialSet = new HashSet<Integer>();
		
		Method [] jobMethods = jobClazz.getDeclaredMethods();
		for (Method jobMethod : jobMethods) {
			Step step = jobMethod.getAnnotation(Step.class);
			if (step != null) {	// ignore method without step annotated
				int serial = step.serial();
				if (serialSet.contains(serial)) {
					throw new NonUniqueSerialException(jobClazz, serial);
				}
			}
		}

		//TODO : validate input params for each method
	}
}
